// Guess My Number
// The classic number guessing game

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main ()
{
	srand(static_cast<unsigned int>(time(0)));       //seed the random number generator;

	int secretNumber = rand() % 100 + 1;             //random number between 1 and 100

	int tries;
	int guess;

	cout << "\nWelcome to Guess My Number\n\n";

	do
	{
		cout << "Enter a guess: ";
		cin >> guess;
		++tries;
		
		if(guess > secretNumber)
		{
			cout << "Too High!\n\n";
		} 
		else if (guess < secretNumber)
		{
			cout << "Too Low!\n\n";
		} 
		else 
		{
			cout << "\nThat's it! You got it in " << tries << " guesses!\n\n"; 
		}

	} while(guess != secretNumber);

	system("PAUSE");
	return 0;
}